fix(release): override the scope registry, and dual-publish the npm package - #11
Merged
Merged
Conversation
The `--registry` pin added in the previous commit does not work for a scoped package, and I found out by publishing to the wrong registry. npm resolves the registry for `@matchory/coding-style` from `@matchory:registry`, falling back to the generic `registry` key only when the scope key is unset. `--registry` sets the generic key, so it loses to any scope mapping. Publishing the placeholder with `--registry https://registry.npmjs.org` sent it to GitHub Packages, because a developer .npmrc maps the @matchory scope there. Both `publishConfig.registry` and `--registry` were outranked. `--@matchory:registry=` sets the key that actually wins. Verified against all three combinations by dry-run: `--registry` alone does not retarget, the scope override does. This matters beyond tidiness because libnpmpublish never validates the destination registry, so a provenance-signed release could have landed somewhere unintended and npm would have signed it regardless. Replaced the previous config-inspection warning with a real gate: a dry-run publish using the exact flags, asserting the reported target is npmjs. That tests the resolved behaviour instead of guessing at precedence, which is the mistake that caused this. The stray 0.0.0 in GitHub Packages is harmless in itself, but it exposed a design problem that needs a decision: @matchory/ui is on GitHub Packages while @matchory/coding-style is headed for npmjs, and npm registry configuration is per-scope with no per-package override. A consuming repository therefore cannot take one @matchory package from each. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CEdTd43qLEEE5qCsL1A7gW
npm resolves a registry per scope and offers no per-package override. `@matchory/ui` is proprietary and lives on GitHub Packages, so any repository consuming it maps the whole `@matchory` scope there — and would never find this package on npmjs. Publishing to one registry only would have meant every internal consumer either cannot install this package or must stop consuming `@matchory/ui` the way it does today. So the same attested tarball goes to both. Byte-identical, with the SHA-256 verified before each upload, which is what makes "identical" checkable rather than asserted. npmjs stays canonical: public, and the copy that carries the provenance statement. GitHub Packages authenticates with the job's GITHUB_TOKEN, so dual publishing introduces no new credential, and runs in the same gated `release` environment behind the same approval. --provenance is deliberately omitted for GitHub Packages. It neither displays nor verifies npm provenance statements, so a second statement there would be a claim nobody can check; the shared GitHub artefact attestation covers both copies. Verified the retargeting empirically in both directions rather than trusting precedence rules, having already been wrong about them once: the scope override sends the publish to GitHub Packages (proved by the "cannot publish over previously published 0.0.0" conflict, since the misdirected placeholder is there) and to npmjs (clean dry-run). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CEdTd43qLEEE5qCsL1A7gW
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These two commits were pushed to
chore/pin-npm-exactlyafter PR #10 had already merged, so they never reachedmain. Replayed onto main here.mainis currently in a state that would misbehave, which is why this matters rather than being tidy-up.1. The registry override on
maindoes not workmainpins--registry https://registry.npmjs.org. For a scoped package npm resolves the registry from@scope:registryand only falls back to the genericregistrykey that--registrysets — so any scope mapping outranks it.This was found by publishing to the wrong place:
npm publish --registry https://registry.npmjs.orgsent the placeholder to GitHub Packages, because a developer.npmrcmaps@matchorythere. Both--registryandpublishConfig.registrywere overridden.Fixed to
--@matchory:registry=, which sets the key that actually wins. Also replaces the previous config-inspection warning with a real gate: a dry-run publish using the exact flags, asserting the reported target is npmjs and refusing to proceed otherwise. That tests resolved behaviour instead of reasoning about precedence — the mistake that caused this.This is load-bearing because
libnpmpublishnever validates the destination registry, so a provenance-signed release could land somewhere unintended and npm would sign it regardless.2. Dual publish
npm resolves registries per scope with no per-package override.
@matchory/uiis proprietary and lives on GitHub Packages, so any repository consuming it maps the whole@matchoryscope there and would never find this package on npmjs.The same attested tarball now goes to both, byte-identical with the SHA-256 verified before each upload. npmjs stays canonical — public, and the copy carrying provenance. GitHub Packages authenticates with the job's
GITHUB_TOKEN, so no new credential, in the same gatedreleaseenvironment.--provenanceis omitted for GitHub Packages deliberately: it neither displays nor verifies npm provenance, so a second statement would be a claim nobody can check. The shared GitHub artefact attestation covers both copies.Retargeting was verified empirically in both directions rather than trusted.